/obj/machinery/optable/portable_cmo
	name = "CMO mobile operating table"
	desc = "Used for advanced medical procedures. Seems to be movable, neat."
	icon = 'CMO.dmi'
	icon_state = "up"
	density = 1
	anchored = 0
	updatesicon = 0

	New()
		..()

	attackby(obj/item/weapon/W as obj, mob/user as mob)
		if(!anchored)
			return
		return ..()

	verb/make_deployable()
		set category = "Object"
		set name = "Deploy Table"
		set src in oview(1)

		if(anchored)
			if(victim)
				usr << "You can't do that with someone on the table!"
			else
				anchored = 0
				for(var/mob/M in orange(5,src))
					M.show_message("\blue [usr] releases the locks on the table's casters!")
				icon_state = "up"
		else
			anchored = 1
			for(var/mob/M in orange(5,src))
				M.show_message("\blue [usr] locks the table's casters in place!")
			icon_state = "down"

/obj/machinery/optable/portable_cmo/MouseDrop(over_object, src_location, over_location)
	..()
	if((over_object == usr && (in_range(src, usr) || usr.contents.Find(src))))
		if(!ishuman(usr))	return
		if(anchored)	return 0
		visible_message("[usr] collapses \the [src.name]")
		new/obj/item/cmo_op(get_turf(src))
		spawn(0)
			del(src)
		return

/obj/item/cmo_op
	name = "CMO mobile operating table"
	desc = "A collapsed mobile operating table that can be carried around."
	icon = 'CMO.dmi'
	icon_state = "surgery_cmo_op"
	item_state = "surgery_cmo"
	w_class = 3.0

	attack_self(mob/user)
		var/obj/machinery/optable/portable_cmo/P = new /obj/machinery/optable/portable_cmo(user.loc)
		P.add_fingerprint(user)
		del(src)

/obj/item/weapon/storage/briefcase/surgery_cmo
	icon = 'CMO.dmi'
	icon_state = "surgery_cmo"
	name = "CMO surgery equipment bag"
	desc = "Heavy and full of sharp things."
	item_state = "surgery_cmo"
	w_class = 3.0

	New()
		..()
		contents = list()
		sleep(1)
		new /obj/item/weapon/circular_saw(src)
		new /obj/item/weapon/hemostat(src)
		new /obj/item/weapon/scalpel(src)
		new /obj/item/weapon/retractor(src)
		new /obj/item/weapon/cautery(src)
		new /obj/item/weapon/surgical_tool/bonegel(src)
		new /obj/item/weapon/surgical_tool/bonesetter(src)